package com.yyx.demo.config;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.sql.SQLException;

public class MySqlsession {
    private Excutor excutor = new MyExcutor();
    private MyConfiguration myConfiguration = new MyConfiguration();

    public <T> T selectOne (Function statment,Object parameter) throws SQLException, IllegalAccessException, InvocationTargetException, InstantiationException {
        return excutor.query(statment, parameter);
    }

    public <T> T getMapper(Class<T> tClass){
        //动态代理
        return (T) Proxy.newProxyInstance(tClass.getClassLoader(),new Class[]{tClass},
                new MyMapperProxy(myConfiguration,this));
    }

}
